Imports CapaDeDatos
Imports System.Web
Public Class nLogin
    Public Login As CapaDeDatos.dLogin = New CapaDeDatos.dLogin
    Public Personal As CapaDeDatos.dPersonal = New CapaDeDatos.dPersonal
    Public TipoUsuario As CapaDeDatos.dTipoUsuario = New CapaDeDatos.dTipoUsuario
    Public Function Existe(ByVal Usuario As String, ByVal legajo As Integer) As Boolean
        Return Login.ExisteUsuario(Usuario, legajo)
    End Function
    Public Function GrupoUsuario(ByVal Usuario As String) As DataSet
        Return Login.GrupoUsuario(Usuario)
    End Function
    Public Function IngresoCorrecto(ByVal Usuario As String, ByVal clave As String) As Boolean
        Return Login.Ingreso(Usuario, clave)
    End Function
    Public Function Inserta(ByVal Legajo As Integer, ByVal Nombre As String, ByVal Clave As String, ByVal Tipo As Integer) As Boolean
        Return Login.InsertaUsuario(Legajo, Nombre, Clave, Tipo)
    End Function
    Public Function Listar(ByVal Logon As Integer, ByVal Legajo As Integer, ByVal Nombre As String, ByVal Clave As String, ByVal Tipo As Integer) As DataSet
        Return Login.ListarLogin(Logon, Legajo, Nombre, Clave, Tipo)
    End Function
    Public Function ListarTodos(ByVal Logon As Integer, ByVal Legajo As Integer, ByVal Nombre As String, ByVal Clave As String, ByVal Tipo As Integer) As DataSet
        Dim dtsPrincipal As DataSet
        dtsPrincipal = Login.ListarLogin(Logon, Legajo, Nombre, Clave, Tipo)
        dtsPrincipal.Tables(0).Columns.Add("LegajoNombre")
        dtsPrincipal.Tables(0).Columns.Add("TipoUsuario")
        Dim i As Integer
        For i = 0 To dtsPrincipal.Tables(0).Rows.Count - 1
            Try
                dtsPrincipal.Tables(0).Rows(i)("LegajoNombre") = Personal.ListarNombres(dtsPrincipal.Tables(0).Rows(i)("Legajo").ToString(), "").Tables(0).Rows(0)("NombreApellido").ToString()
            Catch ex As Exception
                dtsPrincipal.Tables(0).Rows(i)("LegajoNombre") = "Error, Nombre no Encontrada"
            End Try
            Try
                dtsPrincipal.Tables(0).Rows(i)("TipoUsuario") = TipoUsuario.Listar(dtsPrincipal.Tables(0).Rows(i)("idTipoUsuario").ToString(), "").Tables(0).Rows(0)("Descripcion").ToString()
            Catch ex As Exception
                dtsPrincipal.Tables(0).Rows(i)("TipoUsuario") = "Error, Usuario no Encontrado"
            End Try
        Next
        Return dtsPrincipal
    End Function
    Public Function Eliminar(ByVal Logon As Integer, ByVal Legajo As Integer, ByVal TipoUsuario As Integer) As Boolean
        Return Login.EliminarLogin(Logon, Legajo, TipoUsuario)
    End Function
    Public Function Modificar(ByVal Logon As Integer, ByVal Legajo As Integer, ByVal Nombre As String, ByVal Clave As String, ByVal TipoUsuario As Integer) As Boolean
        Return Login.ModificaLogin(Logon, Legajo, Nombre, clave, TipoUsuario)
    End Function

End Class
